package com.moorror.codegenvel.common.table.bean;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.moorror.codegenvel.common.table.TreeLineObject;
import com.moorror.codegenvel.common.table.TreeLineUpdateContext;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.compress.utils.Lists;

import java.io.Serializable;
import java.util.List;
import java.util.function.Consumer;

/**
 * @Author jiyanghuang
 * @Date 2023/9/17 13:30
 */
public abstract class AbstractTableStringRow<T extends TreeLineObject> implements TreeLineObject<T>, Serializable {

    @Getter
    protected List<T> children = Lists.newArrayList();

    /**
     * 在树的第几层
     */
    @Getter
    @Setter
    protected int treeLevel;

    @JsonIgnore
    protected Consumer<TreeLineUpdateContext> consumer;

    @Override
    public void updateRow(TreeLineUpdateContext<T> context) {
        if(null != consumer){
            consumer.accept(context);
        }
    }
}
